<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	
	String _db = user.getDbType();
	Map<String,List<Map<String, String>>> dicMap = user.getDicMap();
	List<Map<String, String>> list = null;
	String temp = "";
	String tbe_employment_forms = "";//用工形式
	String tbe_marital_status = "";//婚姻状态
	String tbe_status = "";//员工状态
	
	list = dicMap.get("101");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			if("31".equals(map.get("tmgd_id"))){
				continue;
			}
			tbe_employment_forms += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("27");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
	list = null;
	list = dicMap.get("102");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>人员家庭</title>
		<base href="<%=basePath%>"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />

		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>

		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		
		
<script type="text/javascript">
var _db = '<%=_db%>';

_jsonObj.classname = "com.wxtf.platform.main.employee.EmpFamilyAction";
_jsonObj.methodname = "queryPage";
_jsonObj.logicdata = "[{\"types\":\"init\"}]";

var _jsonObj0 = {
	"classname":"com.wxtf.platform.main.employee.EmployeeAction",
	"methodname":"listAll",
	"logicdata":"[{\"tbe_name\":\"\",\"tbe_idcard\":\"\",\"tbe_sex\":\"\"}]"
};

var win;//人员新建/修改弹出框
var win4;//机构弹出框
var grid1;//人员表格
var win1;//高级检索弹出框
var win2;//配偶选人
var grid0;//选人员表格

$(function(){
	
	grid1 = $("#emp-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,
		columns: [
			{ display: '机构名称', name: 'org_name', width:150, align:'left' },
			{ display: '姓名', name: 'tbe_name', width: 80, align: 'left',render: function(record, index, value, oth){
					return " <a href='javascript:addData(" + JSON.stringify(record) + ")'>"+value+"</a>";
				} },
			{ display: '性别', name: 'tbe_sex', width: 60, align: 'center' },
			{ display: '出生日期', name: 'tbe_birthday', width: 100, align: 'left' },
			{ display: '身份证号', name: 'tbe_idcard', width: 180, align: 'left' },
			{ display: '配偶姓名', name: 'tbfi_spouse_name',width: 100, align: 'left',isSort : false},
			{ display: '配偶性别', name: 'tbfi_spouse_sex',width: 80, align: 'center',isSort : false},
			{ display: '配偶出生日期', name: 'tbfi_spouse_birthday',width: 100, align: 'left',isSort : false},
			{ display: '配偶身份证号', name: 'tbfi_spouse_idcard',width: 180, align: 'left',isSort : false},
			{ display: '家庭电话', name: 'tbe_family_phone', width: 100, align: 'left' },
			{ display: '家庭住址', name: 'tbe_address', width: 250, align: 'left' },
			{ display: '家庭子女数', name: 'tbfi_children_num',width: 100, align: 'left',isSort : false  },
			{ display: '男孩数', name: 'tbfi_children_mnum',width: 100, align: 'left',isSort : false  },
			{ display: '女孩数', name: 'tbfi_children_fnum',width: 100, align: 'left',isSort : false },
			{ display: '员工状态', name: 'tbe_status', width: 100, align: 'left',
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("102");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%temp = map.get("tmgd_name");%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			},
			{ display: '婚姻状态', name: 'tbe_marital_status', width: 100, align: 'left',
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%temp = map.get("tmgd_name");%>
						return '<%=temp%>';
					}
					<%
						}
					}
					%>
					return value;
				}
			},
			{ display: '查看', name:'edit',width:60,isSort:false,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/search.gif' onclick='addData(" + JSON.stringify(record) + ")'></img>";
				}
			}
		]
	});

});

/*
 * 新增/修改人员
 */
function addData(row){
	var bool = false;
	if(row){
		bool = true;
	}
	
	if(!row){
		var rows = grid1.getSelecteds();
		if(rows.length != 1){
			succMsgTip('请选择一个用户再新建');
			return;
		}
		row = rows[0];
	}
	document.getElementById('emp-form').reset();
	
	if(win == null){
		win = initWindowByDiv2('empAdd-div', '编辑家庭信息', 880, 370 ,closeWin);
	}else{
		win.show();
	}
	
	$('#org_id').val(row.org_id);
	$('#tbe_id').val(row.tbe_id);
	$('#tbe_name').val(row.tbe_name);
	$('#tbe_spell_code').val(row.tbe_spell_code);
	$('#tbe_work_permit').val(row.tbe_work_permit);
	$('#tbe_sex').val(row.tbe_sex);
	var temp1 = '';//row.tbe_marital_status
	<%
		list = dicMap.get("27");
		if(null != list && list.size() > 0){
			for(Map<String, String> map: list){
	%>
		if(row.tbe_marital_status == '<%=map.get("tmgd_id")%>'){
			temp1 = '<%=map.get("tmgd_name")%>';
		}
	<%
			}
		}
	%>
	
	$('#tbe_marital_status').val(temp1);
	if(bool){
		$('#tbfi_id').val(row.tbfi_id);
		$("[name='checkbox1']").attr("checked", row.tbfi_spouse_is_join == 1);
		$('#tbfi_spouse_is_join').val(row.tbfi_spouse_is_join);
		//document.getElementById('empBtn').disabled = (row.tbfi_spouse_is_join != 1);
		
		$('#tbe_spouse_id').val(row.tbe_spouse_id);
		$('#tbfi_spouse_name').val(row.tbfi_spouse_name);
		$('#tbfi_spouse_sex').val(row.tbfi_spouse_sex);
		$('#tbfi_spouse_age').val(row.tbfi_spouse_age);
		$('#tbfi_spouse_birthday').val(row.tbfi_spouse_birthday);
		$('#tbfi_spouse_idcard').val(row.tbfi_spouse_idcard);
		$('#tbfi_spouse_department').val(row.tbfi_spouse_department);
		$('#tbfi_spouse_position').val(row.tbfi_spouse_position);
		$('#tbe_spell_code').val(row.tbe_spell_code);
		$('#tbfi_phone').val(row.tbfi_phone);
		$('#tbfi_mobile').val(row.tbfi_mobile);
		$('#tbfi_address').val(row.tbfi_address);
		$('#tbfi_peo_num').val(row.tbfi_peo_num == '' ? 1 : row.tbfi_peo_num);
		$('#tbfi_children_num').val(row.tbfi_children_num == '' ? 0 : row.tbfi_children_num);
		$('#tbfi_children_mnum').val(row.tbfi_children_mnum == '' ? 0 : row.tbfi_children_mnum);
		$('#tbfi_children_fnum').val(row.tbfi_children_fnum == '' ? 0 : row.tbfi_children_fnum);
		$('#tbfi_memo').val(row.tbfi_memo);
		$('#tbfi_valid').val(row.tbfi_valid);
		$('#tbe_sex').val(row.tbe_sex);
		$('#tbe_age').val(row.tbe_age);
		$('#tbe_birthday').val(row.tbe_birthday);
		$('#tbe_idcard').val(row.tbe_idcard);
		$('#tbe_position').val(row.tbe_position);
		$('#org_name').val(row.org_name);
		$('#reserve1').val(row.reserve1);
		$('#reserve2').val(row.reserve2);
		$('#reserve3').val(row.reserve3);
		$('#reserve4').val(row.reserve4);
		$('#reserve5').val(row.reserve5);
		$('#create_by').val(row.create_by);
		$('#create_time').val(row.create_time);
		$('#last_modify_by').val(row.last_modify_by);
		$('#last_modify_time').val(row.last_modify_time);
		$('#tbe_marital_status').val(row.tbe_marital_status);
        $('#tbe_marital_condition').val(row.tbe_marital_condition);
	}
}


/*
 * 条件查询
 */
function serch1(){
	var orgIds = $('#org2').val();
	var tbe_employment_forms = $('#ser5').val();
	var tbe_work_permit = $('#ser3').val();
	var tbe_name = $('#ser1').val();
	var tbe_idcard = $('#ser4').val();
	var tbfi_spouse_name = $('#ser7').val();
	var tbfi_spouse_idcard = $('#ser6').val();
	
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_employment_forms\":\"' + tbe_employment_forms
			+ '\",\"tbe_work_permit\":\"' + tbe_work_permit + '\",\"tbe_name\":\"' + tbe_name
			+ '\",\"tbe_spell_code\":\"\",\"tbe_idcard\":\"' + tbe_idcard
			+ '\",\"tbfi_spouse_name\":\"' + tbfi_spouse_name + '\",\"tbfi_spouse_idcard\":\"' + tbfi_spouse_idcard
			+ '\",\"types\":\"serch1\"}]';
	grid1.loadData();
}

</script>
	</head>
	<body>
		<table class="serTable">
			<tr>
				<td>
					机构：<select id="org2" style=" width: 164px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
				</td>
				<td>姓名：<input id="ser1" style=" width: 160px;"/></td>
				<td>身份证：<input id="ser4" style=" width: 160px;"/></td>
			</tr>
			<tr>
				<td>
					用工形式：<select id="ser5" style=" width: 164px;">
						<option value="0">全部</option>
						<%=tbe_employment_forms%>
					</select>
				</td>
				<td>配偶姓名：<input id="ser7" style=" width: 160px;"/></td>
				<td>配偶身份证：<input id="ser6" style=" width: 160px;"/></td>
				<td><input class="btn2" value="搜索" type="button" onclick="serch1();" /></td>
			</tr>
		</table>
		
		<div id="emp-grid"></div>
		
		<div id="empAdd-div" style="display: none;">
			<form id="emp-form" name="emp-form">
				<input type="hidden" id="tbe_id" name="tbe_id" value="" />
				<input type="hidden" id="tbfi_id" name="tbfi_id" value="" />
				<input type="hidden" id="org_id" name="org_id" value="" />
				<input type="hidden" id="tbe_age" name="tbe_age" value="" />
				<input type="hidden" id="tbe_birthday" name="tbe_birthday" value="" />
				<input type="hidden" id="tbe_idcard" name="tbe_idcard" value="" />
				<input type="hidden" id="tbe_position" name="tbe_position" value="" />
				<input type="hidden" id="tbe_spell_code" name="tbe_spell_code" value="" />
				<!-- tbe_spouse_id 配偶员工ID -->
				<input type="hidden" id="tbe_spouse_id" name="tbe_spouse_id" value="" />
				<!-- reserve1 配偶单位ID -->
				<input type="hidden" id="tbfi_valid" name="tbfi_valid" value="1" />
				<input type=hidden id="org_name" name="org_name" value="" />
				<input type=hidden id="reserve1" name="reserve1" value="" />
				<input type="hidden" id="reserve2" name="reserve2" value="" />
				<input type="hidden" id="reserve3" name="reserve3" value="" />
				<input type="hidden" id="reserve4" name="reserve4" value="" />
				<input type="hidden" id="reserve5" name="reserve5" value="" />
				<input type="hidden" id="create_by" name="create_by" value="" />
				<input type="hidden" id="create_time" name="create_time" value="" />
				<input type="hidden" id="last_modify_by" name="last_modify_by" value="" />
				<input type="hidden" id="last_modify_time" name="last_modify_time" value="" />
				<input type="hidden"  id="tbfi_peo_num" name="tbfi_peo_num" />
				<input type="hidden" id="tbfi_memo" name="tbfi_memo" />
				<input type="hidden" id="tbfi_spouse_age" name="tbfi_spouse_age" />
				<input type="hidden" id="tbfi_spouse_is_join" name="tbfi_spouse_is_join" value="0" />
				
				<table class="form_table">
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
								<img src="ligerUI/skins/icons/communication.gif"/>
								<span>员工基本信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">员工姓名：</td>
						<td><input class="textbg1" id="tbe_name" name="tbe_name" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">员工编号：</td>
						<td><input class="textbg1" id="tbe_work_permit" name="tbe_work_permit" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">员工性别：</td>
						<td><input class="textbg1" id="tbe_sex" name="tbe_sex" readonly="readonly" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">婚姻状态：</td>
						<td>
							<select id="tbe_marital_status" name="tbe_marital_status" style=" width: 182px; margin-left: 1px;">
								<%=tbe_marital_status %>
							</select>
						</td>
						<td></td>
					</tr>
					
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
								<img src="ligerUI/skins/icons/communication.gif"/>
								<span>配偶基本信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">一汽员工：</td>
						<td style=" text-align: left;">
							<input id="checkbox1" name="checkbox1" type="checkbox"/>是
						</td>
						<td></td>
						<td class="form_label">姓名：</td>
						<td><input class="textbg1" id="tbfi_spouse_name" name="tbfi_spouse_name" readonly="readonly" validate="{maxlength:32}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">性别：</td>
						<td>
							<select id="tbfi_spouse_sex" name="tbfi_spouse_sex" style=" width: 182px;">
								<option value="男">男</option>
								<option value="女">女</option>
							</select>
						</td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">出生日期：</td>
						<td><input class="textbg1" id="tbfi_spouse_birthday" name="tbfi_spouse_birthday" readonly="readonly" /></td>
						<td></td>
						<td class="form_label">身份证号：</td>
						<td><input class="textbg1" id="tbfi_spouse_idcard" name="tbfi_spouse_idcard" readonly="readonly"  validate="{maxlength:32}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">单位：</td>
						<td><input class="textbg1" id="tbfi_spouse_department" name="tbfi_spouse_department" readonly="readonly"  validate="{maxlength:64}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">职务：</td>
						<td>
							<input class="textbg1" id="tbe_spell_code" name="tbe_spell_code" onMouseOver="this.style.borderColor='#4fa8e6'"	onMouseOut="this.style.borderColor='#A1A3A1'" />
						</td>
						<td></td>
					</tr>
					
					<tr>
						<td colspan="9" align="left">
							<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
								<img src="ligerUI/skins/icons/communication.gif"/>
								<span>家庭基本信息</span>
							</div>
						</td>
					</tr>
					<tr>
						<td class="form_label">家庭电话：</td>
						<td><input class="textbg1" id="tbfi_phone" name="tbfi_phone" readonly="readonly"  validate="{maxlength:32}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">紧急电话：</td>
						<td><input class="textbg1" id="tbfi_mobile" name="tbfi_mobile" readonly="readonly" validate="{maxlength:32}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">家庭地址：</td>
						<td><input class="textbg1" id="tbfi_address" name="tbfi_address" readonly="readonly" validate="{maxlength:128}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
					</tr>
					<tr>
						<td class="form_label">家庭子女数：</td>
						<td><input class="textbg1" id="tbfi_children_num" name="tbfi_children_num" readonly="readonly" validate="{digits:true,max:99}" value="0" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">男孩数：</td>
						<td><input class="textbg1" id="tbfi_children_mnum" name="tbfi_children_mnum" readonly="readonly" validate="{digits:true,max:99}" value="0" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
						<td class="form_label">女孩数：</td>
						<td><input class="textbg1" id="tbfi_children_fnum" name="tbfi_children_fnum" readonly="readonly" validate="{digits:true,max:99}" value="0" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
						<td></td>
					</tr>
					<tr><td><br /></td></tr>
				</table>
			</form>
		</div>
		
	</body>
</html>









